<?php
namespace Common\Model;
use Think\Model;
class FeeModel extends Model {
    public $modelName = '交费';
    public $modelIcon = 'icon-jpy';
    public $notAuthority = true;
    public $excel = true;
    public $update = false;
    public $detail = false;
    public $delete = true;
    protected $_auto = [
        ['create_time', 'strtotime', 3, 'function'],
        ['update_time', 'strtotime', 3, 'function'],
        ['create_time', 'time', 1, 'function'],
        ['update_time', 'time', 2, 'function'],
    ];
    protected $_validate = [
        ['id', 'require', 'ID必须填写!'],
        ['student_id', 'require', '所在学生必须填写!'],
        ['tuition_id', 'require', '所在学费必须填写!'],
        ['name', 'require', '缴费经办人必须填写!'],
        ['create_time', 'require', '创建时间必须填写!'],
        ['update_time', 'require', '更新时间必须填写!'],
    ];
    public $fieldMap = [
        'id'=>[
            'type'=>'input',
            'name'=>'ID',
            'list'=>true,
            'search'=>true,
            'input'=>false,
            'required'=>true,
            'detail'=>true,
            'excel'=>true,
            'content'=>'',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
        'student_id'=>[
            'type'=>'foreign',
            'name'=>'学生',
            'list'=>true,
            'search'=>false,
            'input'=>true,
            'required'=>true,
            'detail'=>true,
            'excel'=>true,
            'content'=>'student,id,name,select',
            'list_specify'=>' 
            <php>
            $student=D("Student")->where(["id"=>$vo["student_id"]])->find();
            </php>
            <td class="center">
            {$student["name"]}
            </td>'
            ,
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
         'class_id'=>[
            'type'=>'foreign',
            'name'=>'所在班级',
            'list'=>true,
            'search'=>true,
            'input'=>true,
            'required'=>true,
            'detail'=>true,
            'excel'=>false,
            'content'=>'class,id,name,select',
            'list_specify'=>'
            <php>
            $student=D("Student")->where(["id"=>$vo["student_id"]])->find();
            $class=D("Class")->where(["id"=>$student["class_id"]])->find();
            $grade=D("Grade")->where(["id"=>$class["grade_id"]])->find();
            $major=D("Major")->where(["id"=>$class["major_id"]])->find();
            </php>
            <td class="center">
            {$grade["name"]}{$major["name"]}{$class["name"]}
            </td>
            ',
            'update_specify'=>'',
            'detail_specify'=>'',
            'search_specify'=>'  
            <div class="col-md-3 search-input-div">
                    <select name="searchMap[class_id]" id="class_id" class="width-100 search-select">
                        <option value="" class="search-select-default-option">所在班级</option>
                        <php>$foriegnModel = D("class")->select();</php>
                        <volist name="foriegnModel" id="vo">
                        <php>
                           $major=D("major")->where(["id"=>$vo["major_id"]])->find();
                           $grade=D("grade")->where(["id"=>$vo["grade_id"]])->find();
                        </php>
                        <option value="{$vo[\'id\']}" <if condition ="$searchMap[\'class_id\'] eq $vo[\'id\']"> selected </if>>{$grade["name"]}{$major["name"]}{$vo[\'name\']}</option>
                        </volist>
                    </select>
                </div>',

             'export_specify'=>'
              $class=D("class")->where(["id"=>$value])->find();
              $grade=D("grade")->where(["id"=>$class["grade_id"]])->find();
              $major=D("major")->where(["id"=>$class["major_id"]])->find();
              return $grade["name"].$major["name"].$class["name"];
            ',

        ],
        'identity'=>[
            'type'=>'input',
            'name'=>'身份证号',
            'list'=>true,
            'search'=>true,
            'input'=>true,
            'required'=>true,
            'detail'=>true,
            'excel'=>false,
            'content'=>'',
            'list_specify'=>'
            <php>
            $student=D("Student")->where(["id"=>$vo["student_id"]])->find();
            </php>
            <td class="center">
            {$student["identity"]}
            </td>
            ',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
          'term_id'=>[
            'type'=>'input',
            'name'=>'学期及交费项',
            'list'=>true,
            'search'=>false,
            'input'=>true,
            'required'=>true,
            'detail'=>true,
            'excel'=>false,
            'content'=>'',
            'list_specify'=>'
            <php>
            $tuition=D("Tuition")->find($vo["tuition_id"]);
            $term=D("Term")->where(["id"=>$tuition["term_id"]])->find();
            </php>
            <td class="center">
            {$term["name"]}
            </td>
            ',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],

        'tuition_id'=>[
            'type'=>'foreign',
            'name'=>'应交学费',
            'list'=>true,
            'search'=>false,
            'input'=>true,
            'required'=>true,
            'detail'=>true,
            'excel'=>true,
            'content'=>'tuition,id,money,select',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
        'over'=>[
            'type'=>'input',
            'name'=>'实交学费',
            'list'=>true,
            'search'=>false,
            'input'=>false,
            'required'=>false,
            'detail'=>true,
            'excel'=>true,
            'content'=>'',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
        'name'=>[
            'type'=>'input',
            'name'=>'缴费经办人',
            'list'=>true,
            'search'=>false,
            'input'=>false,
            'required'=>true,
            'detail'=>true,
            'excel'=>true,
            'content'=>'',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
        'water'=>[
            'type'=>'input',
            'name'=>'流水号',
            'list'=>true,
            'search'=>false,
            'input'=>false,
            'required'=>false,
            'detail'=>true,
            'excel'=>true,
            'content'=>'',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
            'export_specify'=>'return "\'".$value;',
        ],
        'quit'=>[
            'type'=>'input',
            'name'=>'退费',
            'list'=>true,
            'search'=>false,
            'input'=>false,
            'required'=>false,
            'detail'=>true,
            'excel'=>true,
            'content'=>'',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
        'way'=>[
            'type'=>'input',
            'name'=>'缴费方式',
            'list'=>true,
            'search'=>false,
            'input'=>false,
            'required'=>false,
            'detail'=>true,
            'excel'=>true,
            'content'=>'',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
        'create_time'=>[
            'type'=>'datetime',
            'name'=>'创建时间',
            'list'=>false,
            'search'=>false,
            'input'=>false,
            'required'=>true,
            'detail'=>true,
            'excel'=>true,
            'content'=>'',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
        'update_time'=>[
            'type'=>'datetime',
            'name'=>'更新时间',
            'list'=>false,
            'search'=>false,
            'input'=>false,
            'required'=>true,
            'detail'=>true,
            'excel'=>true,
            'content'=>'',
            'list_specify'=>'',
            'update_specify'=>'',
            'detail_specify'=>'',
        ],
    ];
}
